#include "mainwindow.h"
#include "./ui_mainwindow.h"
#include "mypushbutton.h"
#include <QString>
#include <QPainter>
#include <QPixmap>
#include <QPushButton>
#include <QAction>
#include <QLabel>

MainWindow::MainWindow(QWidget *parent)
    : QMainWindow(parent)
    , ui(new Ui::MainWindow)
{
    ui->setupUi(this);
    this->setFixedSize(320,600);
    this->setWindowIcon(QIcon(":/res/Coin0001.png"));
    this->setWindowTitle("点石成金");
    // 设置退出功能
    connect(ui->actiontuichu,&QAction::triggered,[=](){
            this->close();
    });

    // 开始按钮
    MyPushButton *StartBtn = new MyPushButton(":/res/MenuSceneStartButton.png");
    StartBtn->setParent(this);
    StartBtn->move((this->width() - StartBtn->width()) * 0.5, this->height() * 0.7);
    connect(StartBtn,&QPushButton::clicked,[=](){
        qDebug("点击了开始按钮");
        // 做弹跳特效
        StartBtn->ZoomDown();
        StartBtn->ZoomUp();
    });
}

void MainWindow::paintEvent(QPaintEvent *){
    QPainter painter(this);
    QPixmap pix;
    pix.load(":/res/mainBg.png");
    painter.drawPixmap(0,0,this->width(),this->height(),pix);

    // 画背景图标
    pix.load(":/res/Title.png");
    pix = pix.scaled(pix.width()*0.5,pix.height()*0.5);
    painter.drawPixmap(10,30,pix);
}

MainWindow::~MainWindow()
{
    delete ui;
}

